<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: inc.debug.php 535 2015-02-28 11:47:31Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 535 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2015-02-28 11:47:31 +0000 (Sat, 28 Feb 2015) $
*
* 	itdotmedia by dirk mueller co edv-mueller.com
* 	http://www.itdotmedia.de
* 	http://www.edv-mueller.com
*
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

  function echo_d($exp) {
    if (is_array($exp))
      print_r($exp);
    else
      echo($exp);

    die();
  }
  
  function echo_e($exp, $opt='L', $out = 'std') {
  	$opt = strtoUpper($opt);

		if ($out == 'std' && session_id() != 'a9555cf64bd561fe883b9915f3bc6be6') return;

    $fileName = DIR_FS_DOCUMENT_ROOT.'log_app/debug_'.strftime('%Y%m').'.txt';
    $out_msg = '';

    $param = debug_backtrace();
    if ($out=='std' && strpos($opt, 'D') !== false) { print_r($param); die(); }
    $param = $param[0]; // direkt davor

    if (strpos($opt, 'S') !== false)
      $out_msg .= ' '. $param['file'] . ' ';
    if (strpos($opt, 'L') !== false || strpos($opt, 'E') !== false)
      $out_msg .= '#'. $param['line'];
    if (strpos($opt, 'F') !== false)
      $out_msg .= '{'. $param['function']. '}';
    if (strpos($opt, 'C') !== false)
      $out_msg .= '['. $param['class'].']';

    if ($opt!='')
      $out_msg .= ' - ';
    if ($out == 'file')
      $out_msg .= "\n";
    
    if (is_array($exp) || is_object($exp))
      $out_msg .= print_r($exp, true);
    else
      $out_msg .= ($exp);

    if (strpos($opt, 'N') !== false)
      $out_msg .= "\n---\n";

      
    if ($out == 'std')
      echo $out_msg;
    else if ($out == 'file') {
      if ($file = fopen($fileName, 'a')) {
        fwrite($file, '['.strftime('%d-%H:%M:%S').'] ' . $out_msg);
        fwrite($file, "\n");
      }
    }
    
    if ($out=='std' && strpos($opt, 'E') !== false)
      die();
    
  }

?>